<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>批量修改库存信息batchInventoryModify.html</title>
	</head>
	<link rel="stylesheet" href="../css/common.css" />
	<link rel="stylesheet" href="../css/less/common_less.css" />
	<style>
		body{
			background:#ffffff;
		}
		table {						
			border-collapse:collapse;	
			margin:30px auto;	
		}
		th{
			font-weight:normal;
			padding:0 16px;
			background:#f0eeef;
		}
		td{
			padding:0 16px;
			text-align:center;
			background:#fafafa;
		}
		table td,th{
			height:32px;
			border:1px solid #e7e9e8;
			
		}
		
		input{
			border:none;
			width:40px;
			height:32px;
			background:#fafafa;
			outline:none;
			text-align:center;
			font-family:"微软雅黑"
		}
		.btn{
			text-align:center;
			padding-top:30px;
		}
		.btn button{
			width:80px;
			height:30px;
			border:none;
			font-family:"微软雅黑";
			color:white;
			outline:none;
			cursor:pointer;			
		}
		.btn1{
			background:#01a998;
		}
		.btn2{
			background:#a1a4a9;
		}
		p{
		text-align:right;
		padding-right:10px;
		}
	</style>
	<body>
		<p style='line-height:40px;'>您已选择<b id="num">2</b>个航班</p>
		<table>
			<thead class="f868686">
			<tr>
				<th>舱位</th>
				<th>最大数</th>
				<th>开放数</th>
				<th>切位限制数</th>
				<th>散客限制数</th>				
			</tr>
			</thead>
			<tbody>
				<tr>
					<td class="f00aa99">头等舱 (<label class="arrdata0">F</label>)</td>
					<td><input type="text" class="arrdata1"></td>
					<td><input type="text" class="arrdata2"></td>
					<td><input type="text" class="arrdata3"></td>
					<td><input type="text" class="arrdata4"></td>
				</tr>
				<tr>
					<td class="f00aa99">商务舱 (<label class="arrdata0">C</label>)</td>
					<td><input type="text" class="arrdata1"></td>
					<td><input type="text" class="arrdata2"></td>
					<td><input type="text" class="arrdata3"></td>
					<td><input type="text" class="arrdata4"></td>
				</tr>
				<tr>
					<td class="f00aa99">经济舱 (<label class="arrdata0">Y</label>)</td>
					<td><input type="text" class="arrdata1"></td>
					<td><input type="text" class="arrdata2"></td>
					<td><input type="text" class="arrdata3"></td>
					<td><input type="text" class="arrdata4"></td>
				</tr>
			</tbody>
			
		</table>
		<div class='btn'><button class='btn1'>确认</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button class='btn2'>取消</button></div>
		<script type="text/javascript" src="../js/jquery-1.12.4.js" ></script>
		<script type="text/javascript" src="../layer-v2.4/layer/layer.js" ></script>
		<script>
			
			 var url = document.location.href.toString();
			 var u = url.split("=");
			 //alert(u[1]);//通过URL向下一个页面传输的id数据
			 console.log(typeof(u[1]));//string
    		$("#num").text(u[1].split(",").length);//航班的个数
			 $(".btn1").click(function(){
				 var obj={};
				 obj.fltInfoIds=u[1].split(",");//数组id的list
				 var invLegCabinPos=[];
				 var len=$("table>tbody>tr").length;//获取表格行数
				for(var i=0;i<len;i++){
					var json={};
					json.cabin=$(".arrdata0").eq(i).text();
					json.maxCapacity=$(".arrdata1").eq(i).val();//最大数
					json.openCapacity=$(".arrdata2").eq(i).val();//开放数
					json.groupCapacity=$(".arrdata3").eq(i).val();//切位开放数
					json.individualCapacity=$(".arrdata4").eq(i).val();//散客开放数
					invLegCabinPos.push(json);
				}
				 obj.invLegCabinPos=invLegCabinPos;
				
				 //将得到的数据list传输给后台
				 layer.msg('修改中...', {icon: 16,shade: 0.01});
				 $.ajax({
						type:"post",
						url:"../inventory/leg/updateCabinBatch?temp="+Math.random(),
						contentType:'application/json;charset=utf-8',
						data:JSON.stringify(obj),
						async:true,
						success:function(data){
							var data=JSON.parse(data);
							//alert(data.message);
							//layer.msg(data.message);
							if(data.status.toString()=="1001"){
								layer.msg(data.message, {icon: 1,time:1000},function(){
									var index = parent.layer.getFrameIndex(window.name);//获取弹窗索引
									parent.layer.close(index);//关闭弹窗
								});			
							}else{
								//layer.msg(data.message, {icon: 2,time:1000})
								layer.confirm(data.message, {
									title:['修改失败','background-color:#00aa98;color:#fff'],
								   	btn: ['确定'] //按钮
								}, function(){
									layer.closeAll('dialog');
								});
							}
						}
					});
				  
				  
				
			 });
			 //取消执行关闭窗口
    		$(".btn2").click(function(){
    			var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
   				 parent.layer.close(index);
    		});
			 
		</script>
	</body>
</html>
